home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 001a / tlxutl10.zip / COPYCOL.PAS < prev    next >
Pascal/Delphi Source File  |  1991-01-25  |  3KB  |  120 lines

  1. Program CopyColours;
  2.  
  3. { Copyright 1991 By Reuben Sumner }
  4.  
  5. Uses
  6.     Dos;
  7.  
  8. Const
  9.     LookFor : Array [1..12] of String[10] =
  10.         ('deffg','defbg','statfore','statback','bord','mbord','mbback',
  11.         'mfore','mbold','mback','mbar','msel');
  12. { This is an array of strings to search for in config file that indicate
  13.     that they are colours }
  14.  
  15. Label
  16.     AbortProgram;
  17.  
  18. Var
  19.     CColour, BColour, New : Text; { CColour : File with colours to copy
  20.                                             BColour : File to copy colours to
  21.                                             New : File to create with proper colours }
  22.     Correct, Wrong : PathStr;        { Correct : File name with correct colours
  23.                                             Wrong : File name with incorrect colours }
  24.     Colours : Array [1..12] of Byte;    { Array containing colours read in from
  25.                                                 CColour }
  26.     FDir : DirStr;
  27.     FName : NameStr;                    { Strings for breaking up filenames }
  28.     FExt : ExtStr;
  29.  
  30.     Line : String[80];                { Line to read in from files }
  31.     Count, Position : Byte;            { Count : For loop purposes
  32.                                             Position : variable for location of = sign
  33.                                             and other }
  34.     Name : String[10];                { Name of line in config ie "bold" }
  35.     Value : String[40];                { Value for Name ie 10 or "ATDT" }
  36.     Error : Integer;                    { Result code for Val procedure }
  37.  
  38. Begin
  39.     If ParamCount > 0 Then
  40.         If ParamCount <> 2 Then
  41.             Begin
  42.                 WriteLn ('Improper syntax!');
  43.                 WriteLn;
  44.                 WriteLn ('Correct syntax is:');
  45.                 WriteLn ('COPYCOL [input[.CNF] output[.CNF]]');
  46.                 Goto AbortProgram;
  47.             End
  48.         Else
  49.             Begin
  50.                 Correct := ParamStr (1);
  51.                 Wrong := ParamStr (2);
  52.                 FSplit (Correct,FDir,FName,FExt);
  53.                 If FExt = '' Then
  54.                     FExt := '.CNF';
  55.                 Correct := FDir + FName + FExt;
  56.                 FSplit (Wrong,FDir,FName,FExt);
  57.                 If FExt = '' Then
  58.                     FExt := '.CNF';
  59.                 Wrong := FDir + FName + FExt;
  60.             End
  61.     Else
  62.         Begin
  63.             Write ('Enter filename with correct colours:  ');
  64.             ReadLn (Correct);
  65.             Write ('Enter filename with incorrect colours:  ');
  66.             ReadLn (Wrong);
  67.         End;
  68.  
  69.     Assign (CColour,Correct);
  70.     Assign (BColour,Wrong);
  71.  
  72.     FSplit (Wrong,FDir,FName,FExt);
  73.     FExt := 'bak';
  74.     Assign (New,FDir+FName+'.'+FExt);
  75.     {$I-}
  76.     Erase (New);
  77.     {$I+}
  78.     Error := IOResult; { Never used but clears result code }
  79.     Assign (New,Wrong);
  80.  
  81.     Reset (CColour);
  82.     Repeat
  83.         ReadLn (CColour,Line);
  84.         Count := 1;
  85.         Position := Pos ('=',Line);
  86.         Name := Copy (Line,1,Position-1);
  87.         Value := Copy (Line,Position+1,Length(Line)-Position);
  88.         Repeat
  89.             If Name = LookFor [Count] Then
  90.                 Begin
  91.                     Val (Value,Colours[Count],Error);
  92.                Count := 12;
  93.                 End;
  94.             Inc (Count);
  95.         Until Count = 13;
  96.     Until Eof(CColour);
  97.     Close (CColour);
  98.     Reset (BColour);
  99.     Rewrite (New);
  100.  
  101.     Repeat
  102.         ReadLn (BColour,Line);
  103.         Count := 1;
  104.         Position := Pos ('=',Line);
  105.         Name := Copy (Line,1,Position-1);
  106.         Value := Copy (Line,Position+1,Length(Line)-Position);
  107.         Repeat
  108.             If Name = LookFor [Count] Then
  109.                 Begin
  110.                     Str (Colours [Count],Value);
  111.                Count := 12;
  112.                 End;
  113.             Inc (Count);
  114.         Until Count = 13;
  115.         WriteLn (New,Name+'='+Value);
  116.     Until Eof(BColour);
  117.     Close (BColour);
  118.     Close (New);
  119.     AbortProgram:
  120. End.